function [Train, Test] = genTrainTestFile(o, Train, Test)

Train.source = fullfile(o.result_path, 'train.txt');
write2file(Train.source, Train.files);

if ~isempty(Test)
    Test.source = fullfile(o.result_path, 'test.txt');
    write2file(Test.source, Test.files);
end

function write2file(txtfile, filelist)
fid = fopen(txtfile, 'w');
if ischar(filelist)
    fprintf(fid, '%s\n', filelist);
else
    cellfun(@(x)fprintf(fid, '%s\n', x), filelist);
end
fclose(fid);
